package cn.icanci.loopstack.bic.sample.controller;

import java.util.Date;
import java.util.UUID;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import cn.icanci.loopstack.bic.sample.service.OrderService;
import cn.icanci.loopstack.bic.sdk.burying.LoggerBuryingUtils;
import cn.icanci.loopstack.bic.sdk.burying.aop.UseCaseStart;

/**
 * @author icanci
 * @since 1.0 Created in 2023/09/27 14:07
 */
@RestController
@RequestMapping("/order")
public class OrderController {

    @Resource
    private OrderService orderService;

    @GetMapping("/create")
    @UseCaseStart(useCaseKey = "createOrder")
    public String createOrder() {
        String traceId = UUID.randomUUID().toString();
        orderService.createOrder(traceId,new Date());
        LoggerBuryingUtils.info(traceId, "create order success");
        return "create order success";
    }

    @GetMapping("/search")
    @UseCaseStart(useCaseKey = "searchOrder")
    public String searchOrder() {
        String traceId = UUID.randomUUID().toString();
        LoggerBuryingUtils.info(traceId, "search order success start");
        orderService.searchOrder(traceId,new Date());
        LoggerBuryingUtils.info(traceId, "search order success end");
        return "search order success";
    }
}
